# debug_search_client.py
import asyncio
import subprocess
import sys
import os

async def run_server_debug():
    """运行服务器并查看原始输出"""
    process = subprocess.Popen(
        [sys.executable, "search_server.py"],
        env={
            **os.environ,
            "DASHSCOPE_API_KEY": "sk-4e88cf4db3e14894bafaff606d296610"
        },
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        text=True,
        encoding='utf-8',
        errors='replace'
    )

    # 读取输出
    try:
        while True:
            line = process.stdout.readline()
            if line:
                print(f"服务器输出: {line.strip()}")
            else:
                break
    except KeyboardInterrupt:
        process.terminate()

    process.wait()

if __name__ == "__main__":
    asyncio.run(run_server_debug())